package wabjava;
import javax.swing.JOptionPane;
public class pingjunshu {
		public static void main(String args[])
		{
			System.out.println("请输入一串整数，我会计算你输入的所有数中非负数的平均数，当你输入0时，代表着输入结束");
			int youinsum=0;
			int youinnum=0;
			int youin=0;
			int allyouinnum=0;
			String str=JOptionPane.showInputDialog("输入您的数字:");
			youin=Integer.parseInt(str); 
			while(youin!=0)
			{
				if(youin>0)
				{
					youinsum+=youin;
					youinnum++;
					allyouinnum++;
					System.out.println("第"+allyouinnum+"个数是"+youin);
					str=JOptionPane.showInputDialog("请继续输入");
					youin=Integer.parseInt(str); 
				}
				else 
				{
					allyouinnum++;
					System.out.println("第"+allyouinnum+"个数是"+youin);
					 str=JOptionPane.showInputDialog("请继续输入");
					youin=Integer.parseInt(str); 
				}
			}
			double aveyouinsum;
			aveyouinsum=(double)youinsum/youinnum;
			System.out.println("算出来了，非负数的平均数是"+aveyouinsum);
		}
}
